<?php
/**
 * (commands) 财务报表。报告内容周期14天更新
 */
namespace App\Console\Commands\SpApi\Report\CreateAndGet;

use App\Crontab\Daily\SpApi\GrabGetReports;
use App\Logic\Amazon\Api\ReportWork;
use Illuminate\Console\Command;
class SettlementReport extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sp-report:settlement-report {accountId=0}';

    /**
     * The console command description.
     * @var string
     */
    protected $description = 'exe func';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 未使用
     * Execute the console command.
     */
    public function handle()
    {
        $where = [];
        $accountId = $this->argument('accountId');
        if($accountId){
            $where['id'] = $accountId;
        }
//        $period = $this->argument('period');
//        $time = strtotime('midnight first day of -'.$period.' month');
        $reportType = 'GET_V2_SETTLEMENT_REPORT_DATA_FLAT_FILE';
//        $start_time = date('Y-m-01',$time);
//        $end_time = date('Y-m-t');
        $start_time = date('Y-m-01');
        $end_time = date('Y-m-03');
        ReportWork::settlementReport([$reportType],getDateFormat($start_time),getDateFormat($end_time),$where);
//        GrabGetReports::grab([$reportType],getDateFormat($start_time),getDateFormat($end_time),$where);
        $this->info('finish!');
    }
}
